package com.chuyu.cy.controller;

import com.chuyu.cy.contants.ResponseCodeEnum;
import com.chuyu.cy.contants.Result;
import com.chuyu.cy.entity.dto.FeedBackDTO;
import com.chuyu.cy.service.FeedBackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: white-zhou
 * @date: 2024-03-25 20:02
 **/
@RestController
@RequestMapping("/feedback")
@Tag(name = "用户反馈管理")
public class FeedBackController {

    @Resource
    private FeedBackService feedBackService;



    /**
     * 添加反馈
     * @param feedBackDTO 反馈信息
     * @return Result
     */
    @PostMapping("/add")
    @Operation(summary = "添加反馈")
    public Result addFeedBack(@RequestBody FeedBackDTO feedBackDTO) {
        Result result = new Result();

        if (feedBackDTO == null) {
            return result.failure(ResponseCodeEnum.NO_PARAM);
        }

        boolean b = feedBackService.addFeedBack(feedBackDTO);
        if (!b) {
            return result.failure(ResponseCodeEnum.SYSTEM_ERROR);
        }

        return result.success();
    }
}
